<template>
	<view class="container app_content_color">
		<login-notice-view v-if="showLogin" />
		<block v-else>
			<block v-for="(item,index) in items" :key="index">
				<view class="title app_title_color">{{item.board_category_name}}</view>
				<view class="sub_board_content grid-content">
					<view class="sub_board_cell_content" v-for="(subItem,subIndex) in item.board_list"
						:key="subIndex" @tap="boardCellTap" :data-item="subItem">
					{{subItem.board_name}}
					</view>
				</view>
			</block>
		</block>
	</view>
</template>

<script>
	import http from "../../utils/http.js"
	export default {
		data() {
			return {
				items: []
			}
		},
		onLoad() {
			this.loadData();
		},
		onShow() {
			let showLogin = getApp().globalData.user == null
			if(this.showLogin != showLogin){
				this.showLogin = showLogin
				if(!showLogin){
					this.loadData()
				}
			}
		},
		methods: {
			loadData() {
				var that = this;
				http.request("forum/forumlist", {}, {
					success: function(data) {
						uni.stopPullDownRefresh();
						that.items = data.list
					},
					fail: function(msg) {
						uni.stopPullDownRefresh();
						uni.showToast({
							title: msg,
							icon: "none"
						})
					}
				})
			},
			boardCellTap: function(e) {
				var item = e.currentTarget.dataset.item;
				uni.navigateTo({
					url: "../forun-post-write/forun-post-write?fNmae=" + item.board_name + "&fid=" + item
						.board_id
				})
			}
		}
	}
</script>



<style lang="scss">
	.title {
		font-size: 30upx;
		margin-top: 30upx;
		margin-left: 30upx;
	}
	
	.sub_board_content {
		margin-left: 30upx;
	}
	
	.sub_board_cell_content {
		display: flex;
		justify-content: center;
		align-items: center;
		border: 1px solid $uni-global-green-color;
		color: $uni-global-green-color;
		font-size: 30upx;
		height: 60upx;
		border-radius: 6upx;
		margin-right: 30upx;
		margin-top: 20upx;
		padding-left: 30upx;
		padding-right: 30upx;
		white-space: nowrap;
	}
	
	
</style>